<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="renderer" content="webkit" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <title>用户登录</title>
    <link rel="stylesheet" href="/static/plugins/layui/css/layui.css" />
    <link rel="stylesheet" href="/templates/theme/default/common/css/style.css" />
    <link rel="icon" href="/templates/theme/default/common/image/code.png" />
</head>
<body>

<div class="login-main">
    <header class="layui-elip">用户登录</header>
    <form class="layui-form" action="javascript:return false;">
        <div class="layui-input-inline">
            <input type="text" name="account" required="required"  lay-verify="required" placeholder="用户名" autocomplete="off" class="layui-input" />
        </div>
        <div class="layui-input-inline">
            <input type="password" name="password" required="required"  lay-verify="required" placeholder="密码" autocomplete="off" class="layui-input" />
        </div>
        <div class="layui-input-inline login-btn">
            <button lay-submit="lay-submit" class="layui-btn" lay-filter="signin">登录</button>
        </div>
        <hr/>
      <!--  <div class="layui-input-inline">
            <button type="button" class="layui-btn layui-btn-primary">QQ登录</button>
        </div>-->
        <!--<div class="layui-input-inline">
            <button type="button" class="layui-btn layui-btn-normal">微信登录</button>
        </div>-->
        <p><a href="/user/reg" class="fl">立即注册</a><a href="javascript:;" class="fr">忘记密码？</a></p>
    </form>
</div>


<script src="/static/plugins/layui/layui.js"></script>
<script type="text/javascript">
    layui.use('form', function() {
        var $ = layui.jquery;
        //监听提交
        layui.form().on('submit(signin)', function(data){
            console.log(data);
            var url = 'doLogin.json';
            $.ajax({
                url: url,
                data: data.field,
                type: 'post',
                dataType: 'json',
                success: function (data) {
                    console.log(data);
                    if(data.code===0) {
                        layer.msg("登录成功");
                        setTimeout("window.location.href='/user/index'", 1000);
                    }else{
                        layer.msg(data.msg);
                    }
                }
            });

            return false;
        });

    });
</script>
</body>
</html>